﻿using DTcms.Common;
using System.Collections.Generic;

namespace DTcms.Web.Mvc.UI.Page
{
    public partial class usercode_edit : BaseController
    {
        protected string action;
        protected int id;
        protected int channel_id = 2;
        protected int category_id;
        protected string redirect = string.Empty;//回传地址
        protected Model.article model = new Model.article();

        /// <summary>
        /// 重写虚方法,此方法在Init事件执行
        /// </summary>
        public usercode_edit()
        {
            var userModel = GetUserInfo();
            action = DTRequest.GetQueryString("action");
            id = DTRequest.GetQueryInt("id");
            category_id = DTRequest.GetQueryInt("category_id");
            if (action.ToLower() == DTEnums.ActionEnum.Edit.ToString().ToLower())
            {
                BLL.article bll = new BLL.article();
                model = bll.GetModel("goods", id);
                if (model == null)
                {
                    redirect = linkurl("error", "?msg=" + Utils.UrlEncode("出错了，您要浏览的页面不存在或已删除！"));
                    return;
                }
                if (model.fields["user_id"] != userModel.id.ToString())
                {
                    redirect = linkurl("error", "?msg=" + Utils.UrlEncode("出错了，您所要修改的并非自己的！"));
                    return;
                }
                category_id = get_category_parent_id(model.category_id);
            }
        }
    }
}
